package com.imufe.chemicalenterprisedangerwarning.service.impl;

import com.imufe.chemicalenterprisedangerwarning.entity.po.DepartmentPO;
import com.imufe.chemicalenterprisedangerwarning.entity.vo.DepartmentVO;
import com.imufe.chemicalenterprisedangerwarning.mapper.DepartmentMapper;
import com.imufe.chemicalenterprisedangerwarning.service.DepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.imufe.chemicalenterprisedangerwarning.util.BeanUtils;
import com.imufe.chemicalenterprisedangerwarning.util.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author BaiBan
 * @since 2022-09-21
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, DepartmentPO> implements DepartmentService {

    @Autowired
    DepartmentMapper mapper;

    @Override
    public DepartmentVO create(String name) {
        DepartmentPO po = new DepartmentPO();
        po.setName(name);
        mapper.insert(po);
        return this.detailed(po.getId());
    }

    @Override
    public DepartmentVO detailed(Long id) {
        DepartmentPO po = mapper.selectById(id);
        return BeanUtils.copyPOJO(po, DepartmentVO.class);
    }
}
